<html>
<head>
<title>用户列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" src="../style/js/jquery-1.4.2.js"></script>
<script language="javascript" src="../style/js/jquery-ztree-2.5.js"></script>
<link rel="stylesheet" href="../style/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script language="javascript" src="../script/pageCommon.js"
	charset="utf-8"></script>
<script language="javascript" src="../script/PageUtils.js"
	charset="utf-8"></script>
<!--  <script language="javascript" src="../script/DemoData.js" charset="utf-8"></script> -->
<script language="javascript" src="../script/DataShowManager.js"
	charset="utf-8"></script>
<script language="javascript" src="../style/js/privilegeData.js"
	charset="utf-8"></script>
<script language="javascript" src="../style/js/privilegeTree.js"
	charset="utf-8"></script>
<link type="text/css" rel="stylesheet"
	href="../style/blue/pageCommon.css" />
<link rel="stylesheet" type="text/css"
	href="../easyUI/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../easyUI/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../easyUI/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../easyUI/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="../easyUI/plugins/jquery.datagrid.js"></script>
<script type="text/javascript" src="../easyUI/plugins/jquery.form.js"></script>
<script type="text/javascript"
	src="../easyUI/plugins/jquery.validatebox.js"></script>
<script type="text/javascript"
	src="../easyUI/plugins/jquery.validatebox.js"></script>
<link rel="stylesheet" type="text/css"
	href="../easyUI/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../easyUI/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript">
    </script>
</head>
<body>

	<div id="Title_bar">
		<div id="Title_bar_Head">
			<div id="Title_Head"></div>
			<div id="Title">
				<!--页面标题-->
				<img border="0" width="13" height="13"
					src="../style/images/title_arrow.gif" /> 用户管理
			</div>
			<div id="Title_End"></div>
		</div>
	</div>

	<div id="MainArea">
		<table cellspacing="0" cellpadding="0" class="TableStyle" id="dg">
		</table>

		<!-- <div id="TableTail">
			<div id="TableTail_inside">
				<a href="saveUI.html"><img src="../style/images/createNew.png" /></a>
			</div>
		</div> -->

		<div class="ItemBlock_Title1" id="userTitle" style="display: none;">
			<!-- 信息说明 -->
			<div class="ItemBlock_Title1">
				<img border="0" width="4" height="7"
					src="../style/blue/images/item_point.gif" />用户:ww
				<div id="userImage"></div>
			</div>
			<div class="ItemBlock_Title1" id="privilegeTitle"
				style="display: none;">
				<div class="ItemBlock_Title1">
					<img border="0" width="4" height="7"
						src="../style/blue/images/item_point.gif" />选择权限
				</div>
			</div>

			<!-- 表单内容显示 -->
			<div class="ItemBlockBorder" style="display: none;"
				id="privilegeContent">
				<div class="ItemBlock">
					<table cellpadding="0" cellspacing="0" class="mainForm">
						<!--表头-->
						<thead>
							<tr align="LEFT" valign="MIDDLE" id="TableTitle">
								<td width="300px" style="padding-left: 7px;">
									<!-- 如果把全选元素的id指定为selectAll，并且有函数selectAll()，就会有错。因为有一种用法：可以直接用id引用元素 -->
									<input type="checkbox" id="allchecked"
									onchange="privilegeCheckedAll(this.checked,this.id)" /> <label
									for="cbSelectAll">全选</label>
								</td>
							</tr>
						</thead>

						<!--显示数据列表-->
						<tbody id="TableData">
							<tr class="TableDetail1">
								<!-- 显示权限树 -->
								<td>
									<ul id='privilegeTree' class="tree">
								</td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>
			<!-- 表单操作 -->
			<div id="InputDetailBar">
				<image onclick="savePrivilege()" src="../style/images/save.png" />
			</div>
		</div>
		<div id="adduser" style="padding-top: 50px">
			<center>
				<div id="form">
					<form id="ff" method="post" action="regist">
						<table cellpadding="5">
							<tr>
								<td>姓名:</td>
								<td><input class="easyui-textbox" type="text" name="name"
									id="name" data-options="required:true"></input></td>
							</tr>
							<tr>
								<td>账号:</td>
								<td><input class="easyui-textbox" type="text" id="account"
									readonly="readonly" disabled="disabled" name="account"
									data-options="required:true"></input></td>
							</tr>
							<tr>
								<td>学校:</td>
								<td><input class="easyui-textbox" type="text" name="school"
									id="school" data-options="required:true"></input></td>
							</tr>
							<tr>
								<td>学院:</td>
								<td><input class="easyui-textbox" name="college"
									id="college" data-options="multiline:true"></input></td>
							</tr>
							<tr>
								<td>专业:</td>
								<td><input class="easyui-textbox" type="text" name="major"
									id="major" data-options="required:true" /></td>
							</tr>
							<tr>
								<td>班级:</td>
								<td><input class="easyui-textbox" type="text" name="clas"
									id="clas" data-options="required:true" /></td>
							</tr>
							<tr>
								<td>角色：</td>
								<td><input name="role" id="role" value=""></td>
							</tr>
						</table>
						<a class="easyui-linkbutton" onclick="submitForm()">保存</a> <a
							class="easyui-linkbutton" onclick="resert()">重置</a>
					</form>
				</div>
			</center>
			<div style="text-align:center;padding:8px"></div>

		</div>
</body>

<script type="text/javascript">
	$(document).ready(function() {
		$('#dg').datagrid({
			url : 'getAllUser',
			pagePosition : 'bottom',
			pagination : 'true',
			rownumbers : 'true',
			showFooter : 'true',
			showHeader : 'true',
			singleSelect : true,
			toolbar : [ {
				iconCls : 'icon-edit',
				handler : edit
			}, '-', {
				iconCls : 'icon-add',
				handler : adduser
			}, '-', {
				iconCls : 'icon-remove',
				handler : remove
			} ],
			columns : [ [
				{
					field : 'name',
					title : '姓名',
					width : 100,
					align : 'center'
				},
				{
					field : 'account',
					title : '账号',
					width : 200,
					align : 'center'
				},
				{
					field : 'school',
					title : '学校',
					width : 200,
					align : 'center'
				},
				{
					field : 'college',
					title : '学院',
					width : 300,
					align : 'center'
				},
				{
					field : 'major',
					title : '专业',
					width : 300,
					align : 'center'
				},
				{
					field : 'clas',
					title : '班级',
					width : 200,
					align : 'center'
				}
			] ]
		});
		$("#form").attr("hidden", "hidden");
	});

	function adduser() {
		resert();
		$("#form").removeAttr("hidden");
		$('#adduser').window({
			width : 600,
			height : 400,
			modal : true,
			title : '用户添加'
		});
		$("#role").combobox({
			url : 'getAllRole',
			valueField:'id',
			textField:'name'
			
		});
	}
	;

	function submitForm() {
		$("#ff").submit();
		$('#adduser').window('close');
	}
	function clearForm() {
	}

	function remove() {
		//$.messager.alert('警告', '警告消息');
		var info = $("#dg").datagrid("getSelected");
		if(info==null){
			$.messager.alert('警告','请选定一行!');
		}
		$.messager.confirm('确认', '您确认删除吗？', function(r) {
			if (r) {
				$.post("delete", {
					"account" : info.account
				}, function(data, textStatus, req) {
					if (data) {
						$("#dg").datagrid("reload");
					}
				})
			}
		});


	}

	function edit() {
		var info = $("#dg").datagrid("getSelected");
		$.post("edit", {
			"account" : info.account
		}, function(data, textStatus, req) {
			adduser();
			$("#name").val(data.name);
			$("#account").val(data.account);
			$("#school").val(data.school);
			$("#college").val(data.college);
			$("#major").val(data.major);
			$("#clas").val(data.clas);
			$("#role").val(data.role);

		})
	}
	function resert() {
		$("#name").val("");
		$("#account").val("");
		$("#school").val("");
		$("#college").val("");
		$("#major").val("");
		$("#clas").val("");
	}
	$(document).ready(function() {
		
	})
</script>
</html>
